package com.ifengchao.util;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;

/**
 * @Author YiMing
 * @Description:
 * @Date: Created in 上午8:57 2017/10/12
 * @Modified By
 */
public class ImageUtil {

	public static void pictureAlter (String imagePath,String url) throws Exception {
		Thumbnails.of(imagePath)
				.forceSize(600, 300)
				.toFile(url);
	}

	public static void main(String[] args) throws Exception {
		/*String imagePath = "/Users/yiming/Desktop/2.jpg";
		BufferedImage image = ImageIO.read(new File(imagePath));
		Thumbnails.Builder<BufferedImage> builder = null;

		int imageWidth = image.getWidth();
		int imageHeitht = image.getHeight();*/

		/*Thumbnails.of("/Users/yiming/Desktop/22.jpg")
				.forceSize(320, 160)
				.toFile("/Users/yiming/Desktop/2");*/
		pictureAlter("/Users/yiming/Desktop/22.jpg","/Users/yiming/Desktop/222.jpg");
	}
}
